# -*- coding:utf-8 -*-

from flask import current_app, jsonify
from app.get_task_datas import get_datas
from . import main
from config import config


# 积分月末镜像备份
@main.route('/check_score_balance', methods=['POST', 'GET'])
def check_score_balance():
    current_app.logger.info('This is check_score_balance')
    praSql = config['default'].CHECK_SCOREBALANCE_SQL
    check_result = get_datas("check_score_balance", praSql)
    return jsonify({'result': check_result})


@main.route('/check_user_rel', methods=['POST', 'GET'])
def check_user_rel():
    current_app.logger.info('This is check_user_rel')
    praSql = config['default'].CHECK_USERREL_SQL
    check_result = get_datas("check_user_rel", praSql)
    return jsonify({'result': check_result})


@main.route('/check_score_result', methods=['POST', 'GET'])
def check_score_result():
    current_app.logger.info('This is check_score_result')
    praSql = config['default'].CHECK_SCORERESULT_SQL
    check_result = get_datas("check_score_result", praSql)
    return jsonify({'result': check_result})


@main.route('/count_score_result', methods=['POST', 'GET'])
def count_score_result():
    current_app.logger.info('This is count_score_result')
    praSql = config['default'].COUNT_SCORERESULT_SQL
    check_result = get_datas("count_score_result", praSql)
    return jsonify({'result': check_result})


# 批扣数据检查
@main.route('/check_balance_before_0', methods=['POST', 'GET'])
def check_balance_before_0():
    current_app.logger.info('This is check_balance_before_0')
    praSql = config['default'].CHECKBALANCE_BEFORE_0_SQL
    check_result = get_datas("check_balance_before_0", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_after_0', methods=['POST', 'GET'])
def check_balance_after_0():
    current_app.logger.info('This is check_balance_after_0')
    praSql = config['default'].CHECKBALANCE_AFTER_0_SQL
    check_result = get_datas("check_balance_after_0", praSql)
    return jsonify({'result': check_result})


@main.route('/check_two_balance', methods=['POST', 'GET'])
def check_two_balance():
    current_app.logger.info('This is check_two_balance')
    praSql = config['default'].CHECKTWOBALANCE_SQL
    check_result = get_datas("check_two_balance", praSql)
    return jsonify({'result': check_result})


@main.route('/check_cycle', methods=['POST', 'GET'])
def check_cycle():
    current_app.logger.info('This is check_cycle')
    praSql = config['default'].CHECKCYCLE_SQL
    check_result = get_datas("check_cycle", praSql)
    return jsonify({'result': check_result})


@main.route('/check_indb_table', methods=['POST', 'GET'])
def check_indb_table():
    current_app.logger.info('This is check_indb_table')
    praSql = config['default'].CHECKINDBTABLE_SQL
    check_result = get_datas("check_indb_table", praSql)
    current_app.logger.info('-----------------------check_result :%s', check_result)
    return jsonify({'result': check_result})


# 批扣数据统计
@main.route('/writeoff_users_counts', methods=['POST', 'GET'])
def writeoff_users_counts():
    current_app.logger.info('This is writeoff_users_counts')
    praSql = config['default'].COUNT_WRITEOFFUSERS_SQL
    check_result = get_datas("writeoff_users_counts", praSql)
    return jsonify({'result': check_result})


@main.route('/writeoff_fee_counts', methods=['POST', 'GET'])
def writeoff_fee_counts():
    current_app.logger.info('This is writeoff_fee_counts')
    praSql = config['default'].COUNT_WRITEOFFFEE_SQL
    check_result = get_datas("writeoff_fee_counts", praSql)
    return jsonify({'result': check_result})


# 批扣平衡性检查
@main.route('/check_balance_0', methods=['POST', 'GET'])
def check_balance_0():
    current_app.logger.info('This is check_balance_0')
    praSql = config['default'].CHECK_BALANCE_0
    check_result = get_datas("check_balance_0", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_1', methods=['POST', 'GET'])
def check_balance_1():
    current_app.logger.info('This is check_balance_1')
    praSql = config['default'].CHECK_BALANCE_1
    check_result = get_datas("check_balance_1", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_2', methods=['POST', 'GET'])
def check_balance_2():
    current_app.logger.info('This is check_balance_2')
    praSql = config['default'].CHECK_BALANCE_2
    check_result = get_datas("check_balance_2", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_3', methods=['POST', 'GET'])
def check_balance_3():
    current_app.logger.info('This is check_balance_3')
    praSql = config['default'].CHECK_BALANCE_3
    check_result = get_datas("check_balance_3", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_4', methods=['POST', 'GET'])
def check_balance_4():
    current_app.logger.info('This is check_balance_4')
    praSql = config['default'].CHECK_BALANCE_4
    check_result = get_datas("check_balance_4", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_5', methods=['POST', 'GET'])
def check_balance_5():
    current_app.logger.info('This is check_balance_5')
    praSql = config['default'].CHECK_BALANCE_5
    check_result = get_datas("check_balance_5", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_6', methods=['POST', 'GET'])
def check_balance_6():
    current_app.logger.info('This is check_balance_6')
    praSql = config['default'].CHECK_BALANCE_6
    check_result = get_datas("check_balance_6", praSql)
    return jsonify({'result': check_result})


# 积分计算文件入库数据检查
@main.route('/check_calc_log_t', methods=['POST', 'GET'])
def check_calc_log_t():
    current_app.logger.info('This is check_calc_log_t')
    praSql = config['default'].CHECK_SC_CALC_LOG_T
    check_result = get_datas("check_calc_log_t", praSql)
    return jsonify({'result': check_result})


@main.route('/check_calc_log_mm', methods=['POST', 'GET'])
def check_calc_log_mm():
    current_app.logger.info('This is check_calc_log_mm')
    praSql = config['default'].CHECK_SC_CALC_LOG_MM
    check_result = get_datas("check_calc_log_mm", praSql)
    return jsonify({'result': check_result})


@main.route('/check_balance_calc_mm', methods=['POST', 'GET'])
def check_balance_calc_mm():
    current_app.logger.info('This is check_balance_calc_mm')
    praSql = config['default'].CHECK_SC_BALANCE_CALC_MM
    check_result = get_datas("check_balance_calc_mm", praSql)
    return jsonify({'result': check_result})


# 积分生效数据检查
@main.route('/score_effect_check', methods=['POST', 'GET'])
def score_effect_check():
    current_app.logger.info('This is score_effect_check')
    praSql = config['default'].CHECK_SCORE_EFFECT
    check_result = get_datas("score_effect_check", praSql)
    return jsonify({'result': check_result})


# 报表备份进度查询
@main.route('/backup_progress', methods=['POST', 'GET'])
def backup_progress():
    current_app.logger.info('This is backup_progress')
    praSql = config['default'].CHECK_BACKUP_PROGRESS
    check_result = get_datas("backup_progress", praSql)
    return jsonify({'result': check_result})


# 报表备份检查数据
@main.route('/am_balance_mm', methods=['POST', 'GET'])
def am_balance_mm():
    current_app.logger.info('This is am_balance_mm')
    praSql = config['default'].CHECK_AM_BALANCE_BAKUP
    check_result = get_datas("am_balance_mm", praSql)
    return jsonify({'result': check_result})


@main.route('/ag_balance_mm', methods=['POST', 'GET'])
def ag_balance_mm():
    current_app.logger.info('This is ag_balance_mm')
    praSql = config['default'].CHECK_AG_BALANCE_BAKUP
    check_result = get_datas("ag_balance_mm", praSql)
    return jsonify({'result': check_result})


@main.route('/sc_balance_mm', methods=['POST', 'GET'])
def sc_balance_mm():
    current_app.logger.info('This is sc_balance_mm')
    praSql = config['default'].CHECK_SC_BALANCE_BAKUP
    check_result = get_datas("sc_balance_mm", praSql)
    return jsonify({'result': check_result})


@main.route('/am_bill_item_mm', methods=['POST', 'GET'])
def am_bill_item_mm():
    current_app.logger.info('This is am_bill_item_mm')
    praSql = config['default'].CHECK_AM_BILL_ITEM_BAKUP
    check_result = get_datas("am_bill_item_mm", praSql)
    current_app.logger.info('This is am_bill_item_mm' + str(check_result))
    return jsonify({'result': check_result})


@main.route('/test', methods=['POST', 'GET'])
def test():
    current_app.logger.info('-------------------This is test')
